home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / oleo-1_4.lha / oleo-1.4 / key.h < prev    next >
C/C++ Source or Header  |  1993-03-30  |  3KB  |  113 lines

  1. #ifndef KEYH
  2. #define KEYH
  3.  
  4. /*    Copyright (C) 1993 Free Software Foundation, Inc.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this software; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19. /*  t. lord    Thu Jan 21 16:13:14 1993    */
  20.  
  21. #include "global.h"
  22. #include "line.h"
  23.  
  24.  
  25. /*
  26.  * Keymaps and keybinds.
  27.  * Within a keymap, keys are bound to a `struct key'.
  28.  *
  29.  * Normally,  `the_funcs[akey.vector][akey.code]' is the command binding of a
  30.  * key.  However, the akey.vector == -1, then the binding is to another
  31.  * keymap, found by the_maps[akey.code].  The final exception, is that if
  32.  * both vector and code are -1, then the key is unbound.
  33.  */
  34.  
  35. struct cmd_func;
  36.  
  37. struct key
  38. {
  39.   short vector;
  40.   short code;
  41. };
  42.  
  43. /* For commands that take a keysequence argument: */
  44.  
  45. struct key_sequence
  46. {
  47.   int top_map;
  48.   struct line * keys;        /* char_to_string name of the key sequence. */
  49.   struct key cmd;        /* The mapping of the sequence. */
  50. };
  51.  
  52.  
  53. struct keymap
  54. {
  55.   struct keymap *map_next;
  56.   int id;
  57.   struct key keys[256];
  58. };
  59.  
  60. extern int num_maps;
  61. extern struct keymap **the_maps;
  62. extern char **map_names;
  63. extern char **map_prompts;
  64.  
  65. #ifndef CTRL
  66. #define CTRL(X) ((X)&037)
  67. #endif
  68. #ifndef META
  69. #define META(X) ((X)|0200)
  70. #endif
  71.  
  72.  
  73. /* String convention conversion. */
  74.  
  75. #define map_id(NAME)  map_idn(NAME, strlen(NAME))
  76.  
  77. /*
  78.  * Keymap names.  They can be used as indices into the_maps and map_names.
  79.  */
  80. #define MAIN_MAP map_id("main")
  81. #define EDIT_MAP map_id("edit")
  82. #define DIGIT_MAP map_id("digit")
  83. #define NAVIGATE_MAP map_id("navigate")
  84.  
  85.  
  86. #ifdef __STDC__
  87. extern int search_map_for_cmd (struct line * line, int map, int vec, int code);
  88. extern void bind_key (char * keymap, char * function, int ch);
  89. extern void bind_set (char * keymap, char * command, char * keyset);
  90. extern void bind_all_keys (char * keymap, char * function);
  91. extern void write_keys_cmd (FILE *fp);
  92. extern void clear_keymap (struct keymap *m);
  93. extern int map_idn (char *name, int n);
  94. extern void create_keymap (char * mapname, char * parentname);
  95. extern void set_map_prompt (char * map, char * str);
  96.  
  97. #else
  98. extern int search_map_for_cmd ();
  99. extern void bind_key ();
  100. extern void bind_set ();
  101. extern void bind_all_keys ();
  102. extern void write_keys_cmd ();
  103. extern void clear_keymap ();
  104. extern int map_idn ();
  105. extern void create_keymap ();
  106. extern void set_map_prompt ();
  107.  
  108. #endif
  109.  
  110. #endif  /* KEYH */
  111.  
  112.  
  113.